Repository navigation
own: a let given only fields borrows each until the next assignment; a let that only holds parameters owns nothing (TSLANG 56, 57) - #850
Merged
Conversation
…TSLANG 56) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
DefaultLib
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TSLANG_ISSUES 56 and 57, found by compiling powder_sandbox's
-mm=ownbuild (native_ts_graphics as its submodule) with the compiler from main. Write-ups are inTSLANG_ISSUES.md.56: a
letgiven only fields borrows each until the next assignmentlet layout = this.computeLayout; ... if (this.fp16Enabled) { layout = this.computeLayoutFP16; ... }(ntgexamples/nri/16bit_arithmetic_nri.ts) was refused: "borrows a field and cannot be assigned; -mm=own cannot prove that yet".letqualifies (borrowsOnly) when its declaration and every assignment give it a read of a place or a parameter.collectBorrowerUses, with the store asfrom).Store, and rc'sRetainright before it, are taken as that read's borrower and bookkeeping (borrowingAssignmentOf, incheckPlaceRead).letholds another field, in a loop too.letcurrently holds written before a use, directly or through a call;letstored or returned;dir = rotateAround(...)).let, reassigns it, then writes the first field, a read after the loop is taken to see the first field.57: a
letthat only holds parameters owns nothinglet src = order; let dst = scratch; ... const swap = src; src = dst; dst = swap;(ntgcore/octomap_common.ts, the exportedsortDescending) was refused: "a parameter, kept here, but -mm=own cannot make the callers ... give it up". So waslet s = a; return s.length;.letan owning local, so storing a parameter into one counted as keeping the parameter.borrowParametersInLocalsruns at the start of the signature pass, before the facts. It turns aletthat only ever holds parameters, or another suchlet's value, into a plain local and drops rc's counting for it.Shared<T>handles, which own counts, and copyable values such as strings.let, capturing it, or giving it a fresh value. These are refused as they would be for the parameter itself.octomap_common.tscompiles under own, and with itexamples/render_octomap.ts.Effect on the sweep (276 sources, every facts object built)
lets: all gone. What remains indonut_first_person_camera.tsis the camera's two, where a fresh array is assigned.core/modules that don't compile under own: 7 → 6.src/compiles clean.Also noted in
TSLANG_ISSUES.md, for native_ts_graphics rather than the compiler:ray_tracing_extended_scene.ts's exported constructors need@keeps(...). I checked that@keepsworks on a constructor.Tests
00tslang_issue_56.tsand00tslang_issue_57.ts, under every model, JIT and compiled. Both were also run as an exe by hand.own_err_let_borrows_reassigned_overwrittenandown_err_parameter_let_stored.tests.ps1for each model is running; results to follow in a comment.🤖 Generated with Claude Code